<template>
  <div>
    <el-form ref="pram" :model="pram" label-width="100px" @submit.native.prevent>
      <el-form-item label="标题" prop="title">
        <el-input v-model="pram.title" placeholder="标题" />
      </el-form-item>
      <el-form-item label="内容" prop="content">
        <el-input v-model="pram.content" type="textarea" :rows="7" placeholder="内容" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import * as messageApi from '@/api/message.js'
import {Debounce} from '@/utils/validate'
import {mesRead} from "@/api/message.js";
export default {
  // name: "edit"
  components: { },
  props: {
    editData: {
      type: Object,
      default: () => {
        return { rules: [] }
      }
    },
  },
  data() {
    return {
      constants:this.$constants,
      pram: {
        title: null,
        content: null,
        isRead: null,
        id: 0,
      },
    }
  },
  mounted() {
    this.initEditData()
    this.handlerScan()
  },
  methods: {
    close() {
      this.$emit('hideEditDialog')
    },
    initEditData() {
      const { title, content, isRead, id } = this.editData //通过list中slot-scope=“scope“，scope.$index就是该行的下标，scope.row就是该行的数据所有消息对象，有了这两个参数就可以实现编辑、删除功能（this.editData就是scope.row传入的对象参数）
      this.pram.title = title
      this.pram.content = content
      this.pram.isRead = isRead
      this.pram.id = id
    },
    handlerScan() {
      const _pram = {id:this.pram.id}
      !this.pram.isRead && messageApi.mesRead(_pram).then(data => {})
    },
  }
}
</script>

<style scoped>

</style>
